import {getPreComment,getLessonComment} from '../../../api/comment'
Component({
  data:{
  title:"",
  postForm:{
  },

  //评论详情
  commentDetail:{

  }
  },
  methods:{
  onLoad(data:any){
    
   const {seriesId,lessonId,stuId, type} = data
   
   if(type === '学前评价'){
    this.setData({
      postForm:{
        seriesId,
        stuId
      },
      title:type
     })
      this.getPreComment()
   }
   if(type === "课程评价"){
   this.setData({
    postForm:{
      lessonId,
      stuId
    },
    title:type
   })
  this.getCourseComment()
 }
  },
  // 获取学前课程评论
  async getPreComment(){
  const postForm = this.data.postForm as any
  const {data:res,code} = await getPreComment(postForm)
  if(code === 200){
    this.setData({
      commentDetail:res
    })
  }
  },
  // 获取课程评论
  async getCourseComment(){
  const postData = this.data.postForm as any
  const {code, data:res} =  await getLessonComment(postData)  
   if(code === 200){
    this.setData({
      commentDetail:res
    })
   }
  }
  }
})